package org.example.enums;


import lombok.Getter;

/**
 * 卸载步骤
 */

@Getter
public enum EUninstallStep implements ITaskStep {

    START(0,"start","开始",0),
    CHECKHEALTH(10, "checkHealth","健康检查",30),
    UNINSTALL(20, "uninstall","卸载",50),
    CLEAN(30, "clean","清理文件夹",80),
    END(40, "end","结束",100);

    EUninstallStep(int stepNum, String name, String cnName,int process) {
        this.stepNum = stepNum;
        this.name = name;
        this.cnName = cnName;
        this.process = process;
    }

    private int stepNum;
    private String name;
    private String cnName;
    private int process;

    public int getStepNum() {
        return stepNum;
    }

    public ITaskStep getStep(){
        return EUninstallStep.getByStepNum(getStepNum());
    }

    @Override
    public EUninstallStep getNextStepNum() {
        int step = stepNum < CLEAN.getStepNum() ? stepNum + 10 : EUninstallStep.END.getStepNum();
        return EUninstallStep.getByStepNum(step);
    }

    public EUninstallStep getLastStepNum() {
        int step = stepNum > UNINSTALL.getStepNum() ? stepNum - 10 : EUninstallStep.CHECKHEALTH.getStepNum();
        return EUninstallStep.getByStepNum(step);
    }

    public static EUninstallStep getByStepNum(int stepNum) {
        EUninstallStep rs = null;
        for (EUninstallStep step : EUninstallStep.values()) {
            if (step.getStepNum() == stepNum) {
                rs = step;
                break;
            }
        }
        if (rs == null) throw new RuntimeException("EUninstallStep 步骤号错误");
        return rs;
    }
}
